﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Esst.Dto.Response
{
    public class Result
    {
        public bool Success { get; set; }
        public string Reason { get; set; }



        public static implicit operator Result(string message)
        {
            return new Result { Success = false, Reason = message };
        }
        public static implicit operator Result(bool success)
        {
            return new Result { Success = success, Reason = string.Empty };
        }
    }

    public class Result<T>
    {
        public bool Success { get; set; }
        public string Reason { get; set; }

        public T Value { get; set; }

        public static implicit operator Result<T>(T value)
        {
            return new Result<T>() { Success = true, Reason = string.Empty, Value = value };
        }

        public static implicit operator Result<T>(string message)
        {
            return new Result<T>() { Success = false, Reason = message };
        }
        public static implicit operator Result<T>(bool success)
        {
            return new Result<T>() { Success = success, Reason = string.Empty };

        }
    }
}
